const http = require("http");
const url = require("url");
const fs = require("fs");

const server = http.createServer();

server.on("request",(request,response)=>{
    const urlobj = url.parse(request.url);
    if(urlobj.pathname == "/"){
        fs.readFile("./html/index.html",(err,info)=>{
            response.write(info);
            response.end();
        })
    }
    else if(urlobj.pathname.startsWith("/static")){
        fs.readFile(__dirname+urlobj.pathname,(err,info)=>{
            response.write(info);
            response.end();
        })
    }
})

server.listen("8080","localhost")